import java.util.Scanner;
import java.util.Stack;
//Emacs计算器
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while(in.hasNext()){				
			int n=in.nextInt();
			Stack<String> sk=new Stack<String>();
			for (int i = 0; i < n; i++) {
				String s=in.next();
				switch (s) {
				case "+":
					sk.push(String.valueOf(Integer.valueOf(sk.pop())+Integer.valueOf(sk.pop())));
					break;
				case "-":
					sk.push(String.valueOf(-(Integer.valueOf(sk.pop())-Integer.valueOf(sk.pop()))));
					break;
				case "*":
					sk.push(String.valueOf(Integer.valueOf(sk.pop())*Integer.valueOf(sk.pop())));
					break;
				case "/":
					sk.push(String.valueOf(Integer.valueOf(sk.pop())/Integer.valueOf(sk.pop())));
					break;
				default:
					sk.push(s);
					break;
				}
			}
			System.out.println(sk.pop());
		}
	}
}
